<?php

namespace app\common\controller;

use think\Controller;
use think\Exception;
use think\facade\Cache;
use think\facade\Config;
use think\facade\Env;
use think\facade\Log;
use think\facade\Request;

class Common extends Controller
{
    protected $config = null;

    protected function initialize()
    {
        parent::initialize();
        $this->config = get_app_config();

        $runtime_path = Env::get('runtime_path');
        if ( delete_dir_file(	$runtime_path . 'temp/') ) {
//            echo "del";
        }
    }


    /**
     * 输出json 数据
     * @param array $data
     * @param int $code
     * @param string $msg
     */
    protected function echoJson($data = array(),$code = 200,$msg = 'ok')
    {
        $data = array(
            'code' => $code,
            'msg' => $msg,
            'data' => $data
        );
        header('Content-Type: application/json; charset=utf-8');
        exit(json_encode($data));
    }
}
